package com.bootdo.system.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

import com.bootdo.system.dao.FrontlogDao;
import com.bootdo.system.domain.FrontlogDO;
import com.bootdo.system.service.FrontlogService;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;


@Service
public class FrontlogServiceImpl implements FrontlogService {
    @Autowired
    private FrontlogDao frontlogDao;

    @Override
    public FrontlogDO get(Long id) {
        return frontlogDao.get(id);
    }

    @Override
    public List<FrontlogDO> list(Map<String, Object> map) {
        return frontlogDao.list(map);
    }

    @Override
    public int count(Map<String, Object> map) {
        return frontlogDao.count(map);
    }

    @Override
    public int save(FrontlogDO frontlog) {
        return frontlogDao.save(frontlog);
    }

    @Override
    public int update(FrontlogDO frontlog) {
        return frontlogDao.update(frontlog);
    }

    @Override
    public int remove(Long id) {
        return frontlogDao.remove(id);
    }

    @Override
    public int batchRemove(Long[] ids) {
        return frontlogDao.batchRemove(ids);
    }

    @Transactional(propagation = Propagation.REQUIRES_NEW)
    @Override
    public void savelog(Long userid, String content) {

        String beizhu = "请尽快激活或者充值，保持助手的正常运转";
        frontlogDao.deleteFromUseridAndBeizhu(userid,beizhu);
        FrontlogDO frontlogDO = new FrontlogDO();
        frontlogDO.setUserid(userid);
        frontlogDO.setContent(content);
        frontlogDO.setCreatetime(new Date());
        frontlogDO.setBizhongname("USDT");
        frontlogDO.setBeizhu(beizhu);
        save(frontlogDO);
    }



}
